package com.xy.job.admin.controller

import com.xy.job.admin.api.request.JobGroupAddParam
import com.xy.job.admin.api.request.JobGroupQueryParam
import com.xy.job.admin.api.response.PageDTO
import com.xy.job.admin.service.JobGroupService
import com.xy.job.core.api.response.wrapperResponse
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@Tag(name = "JobGroupApi")
@Validated
@RestController
@RequestMapping("/api/jobGroup")
class JobGroupController(
    private var jobGroupService: JobGroupService,
) {

    @Operation(summary = "查询执行器分组")
    @PostMapping("/list")
    fun listJobGroup(@RequestBody @Validated param: JobGroupQueryParam) = wrapperResponse {
        val page = jobGroupService.list(param)
        return@wrapperResponse PageDTO(page)
    }

    @Operation(summary = "新增执行器分组")
    @PostMapping("/add")
    fun addJobGroup(@RequestBody @Validated param: JobGroupAddParam) = wrapperResponse {
        return@wrapperResponse jobGroupService.add(param)
    }
}